<?php

namespace Yolo\Service;

use Yolo\Di\Annotations\Singleton;

/**
 * Pre Processor Registry
 * @author LUSHAOMING
 * @date 2024-12-11
 */
#[Singleton]
class PreProcessorRegistry
{
    protected array $preProcessors = [];

    /**
     * Register a new preprocessor.
     * @param string $name
     * @param callable $callback
     * @return void
     */
    public function register(string $name, callable $callback): void
    {
        $this->preProcessors[$name] = $callback;
    }

    /**
     * Get a preprocessor by name.
     * @param string $name
     * @return callable|null
     */
    public function getProcessor(string $name): ?callable
    {
        return $this->preProcessors[$name] ?? null;
    }
}
